<template>
  <div class="home-tag">
    <el-card class="box-card">
      <div slot="header">
        <span class="box-header"><i class="iconfont icon-24gf-tags2"/>热门标签</span>
        <router-link to="/tag" style="margin-left: 245px; font-size: 12px;text-decoration: none;color: #4c4948;">更多&gt;</router-link>
      </div>
      <div class="tag-list">
        <el-tag size="medium" class="tag-item" v-for="item of tagList" :key="item.id">
          <router-link :to="'/tag/' + item.id">
            {{ item.name }}
          </router-link>
        </el-tag>
      </div>
    </el-card>
  </div>
</template>

<script>
import {listTag} from "@/api";

export default {
  name: "home-tag",
  data() {
    return {
      tagList: []
    }
  },
  created() {
    this.listTag()
  },
  methods: {
    listTag() {
      listTag().then(res => {
        this.tagList = res.data;
      })
    }
  }
}
</script>

<style scoped>
.box-card {
  width: 100%;
  margin-bottom: 20px;
}

.box-header:hover {
  color: red;
  font-weight: bold;
}

.tag-list {
  text-align: center;
}

.tag-item {
  margin: 4px 2px;
}

.tag-list a {
  color: #545454;
  display: inline-block;
  text-decoration: none;
  padding: 0 5px;
  line-height: 1.5;
  transition: all 0.3s;
}

.tag-list a:hover {
  color: #03a9f4 !important;
  transform: scale(1.1);
}
</style>
